package com.sky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sky.entity.Staff;
import com.sky.mapper.StaffMapper;
import com.sky.service.StaffService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 23714
* @description 针对表【staff】的数据库操作Service实现
* @createDate 2024-09-29 10:45:16
*/
@Service
public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff>
    implements StaffService{

    @Resource
    StaffMapper staffMapper;

    /**
     * 根据用户的身份证号码查询改用户是否存在
     * @param userCode 员工身份证
     * @return 员工对象
     */
    @Override
    public Staff loginUser(String userCode) {
        LambdaQueryWrapper<Staff> wra = Wrappers.lambdaQuery();
        wra.eq(Staff::getIdCard,userCode);
        List<Staff> li = staffMapper.selectList(wra);
        if(li!=null && li.size()>0){
            return li.get(0);
        }
        return null;

    }
}




